{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import akshare as ak\n",
    "import pandas as pd\n",
    "from pyfinance import TSeries\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>content</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2021-12-17 19:33:28</td>\n",
       "      <td>&lt;b&gt;【直播进行中】面对英央行强势加息，黄金应如何布局？实时连线金十研究员，专业解读最新持仓...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2021-12-17 19:33:26</td>\n",
       "      <td>&lt;a href=\"https://v.jin10.com/live/index.html#/...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2021-12-17 19:32:17</td>\n",
       "      <td>美国国家过敏症和传染病研究所所长福奇：看到了突破性感染病例，风险较低。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2021-12-17 19:31:20</td>\n",
       "      <td>&lt;b&gt;【行情】现货钯金涨超5%，报1824.27美元/盎司。&lt;/b&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2021-12-17 19:29:01</td>\n",
       "      <td>据俄新社：俄罗斯总统普京称，俄罗斯的“卫星V”新冠疫苗对奥密克戎毒株有效。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2021-12-17 19:25:31</td>\n",
       "      <td>【上海出口集装箱运价指数逼近4900点 再创历史新高】12月17日，上海航运交易所公布最新的...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2021-12-17 19:24:42</td>\n",
       "      <td>12月17日0-18时，浙江绍兴新增确诊病例66例、无症状感染者1例，均在上虞区。（人民日报）</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2021-12-17 19:19:39</td>\n",
       "      <td>【行情】欧盟基准碳价合约下跌11%，报75.28欧元/吨。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2021-12-17 19:19:31</td>\n",
       "      <td>美国国家过敏症和传染病研究所所长福奇：奥密克戎毒株和德尔塔毒株的感染病例都在激增。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2021-12-17 19:18:30</td>\n",
       "      <td>俄罗斯副外长：准备最早在明天就拟议的安全保障开始与美国谈判。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2021-12-17 19:17:15</td>\n",
       "      <td>德国总理朔尔茨发言人：不能保证德国央行行长魏德曼的继任者将于下周三在内阁中做出决定。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2021-12-17 19:15:54</td>\n",
       "      <td>德国总理朔尔茨发言人：德国央行行长候选人将很快公布。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2021-12-17 19:09:44</td>\n",
       "      <td>德国经济部：目前没有迹象表明天然气短缺。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2021-12-17 19:07:31</td>\n",
       "      <td>印度卫生官员：目前还没有足够的数据表明新型药物的有效性。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2021-12-17 19:07:26</td>\n",
       "      <td>【金十图示】2021年12月17日（周五）欧盘市场行情一览</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2021-12-17 19:06:45</td>\n",
       "      <td>习近平在主持会议时强调，要推动发展适合中国国情、政府政策支持、个人自愿参加、市场化运营的个人...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2021-12-17 19:06:40</td>\n",
       "      <td>习近平12月17日下午主持召开中央全面深化改革委员会第二十三次会议，审议通过了《关于加快建设...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2021-12-17 19:05:53</td>\n",
       "      <td>华人置业(00127.HK)在港公告：董事会谨此宣布，私有化计划于计划会议上遭到否决。将本公...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2021-12-17 19:05:23</td>\n",
       "      <td>&lt;b&gt;德国经济部：北溪二号不会在明年1月开始运营。&lt;/b&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2021-12-17 19:04:50</td>\n",
       "      <td>据央视：习近平主持召开中央全面深化改革委员会第二十三次会议强调，加快建设全国统一大市场提高政...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2021-12-17 19:03:43</td>\n",
       "      <td>市场消息：北溪二号第二根管道正在注入天然气。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2021-12-17 19:02:08</td>\n",
       "      <td>欧洲证券及市场管理局：希望与英国央行达成新的协议，以对伦敦清算机构拥有更大的权力。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2021-12-17 19:01:52</td>\n",
       "      <td>欧洲证券及市场管理局：目前切断伦敦欧元清算的成本和风险超过了收益。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2021-12-17 19:01:13</td>\n",
       "      <td>西班牙央行：通胀在2022年前几个月保持高位后将大幅放缓。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2021-12-17 19:01:06</td>\n",
       "      <td>西班牙央行首席经济学家：西班牙经济要到2022年底或2023年初才能达到大流行前的水平。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2021-12-17 19:00:48</td>\n",
       "      <td>西班牙央行：2021年经济增速预期从9月份的6.3%降至4.5%。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2021-12-17 18:58:39</td>\n",
       "      <td>贝壳(BEKE.N)否认浑水做空报告：昨日，浑水公司发布了一份攻击贝壳的做空报告。根据本公司...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2021-12-17 18:57:04</td>\n",
       "      <td>香港特区政府卫生署卫生防护中心17日公布，截至当日零时，香港新增7例新冠肺炎输入病例。其中1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2021-12-17 18:56:11</td>\n",
       "      <td>印度卫生官员：新冠阳性率高的地区应考虑限制性措施。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2021-12-17 18:55:18</td>\n",
       "      <td>印度卫生官员：需要避免不必要的旅行、大规模集会。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2021-12-17 18:54:45</td>\n",
       "      <td>据俄新社：俄罗斯表示美国不应与前苏联国家建立军事关系。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2021-12-17 18:52:45</td>\n",
       "      <td>据俄新社：俄罗斯建议美国不得在前苏联国家建立基地。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2021-12-17 18:52:09</td>\n",
       "      <td>德国卫生部发言人：政府正在调查英国是否应被列为变种病毒感染区。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2021-12-17 18:51:49</td>\n",
       "      <td>土耳其央行：因出现了不健康的价格结构，干预了外汇市场。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2021-12-17 18:48:55</td>\n",
       "      <td>印度卫生官员：已经发现101例奥密克戎毒株感染病例。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2021-12-17 18:48:11</td>\n",
       "      <td>&lt;b&gt;【行情】美元兑土耳其里拉USD/TRY日内涨幅收窄至近5%，报16.50。&lt;/b&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>2021-12-17 18:47:28</td>\n",
       "      <td>市场消息：土耳其央行干预了外汇市场。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>2021-12-17 18:47:14</td>\n",
       "      <td>据俄新社：俄罗斯建议俄罗斯和美国不要在其领土外部署核武器，并撤回已经在其领土外部署的核武器。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>2021-12-17 18:46:39</td>\n",
       "      <td>据俄新社：俄罗斯建议美国在平等安全的基础上合作，不损害彼此的安全。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>2021-12-17 18:46:11</td>\n",
       "      <td>据俄新社：草案显示，俄罗斯和北约承诺不会在可能击中对方领土的地区部署中程和短程导弹。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>2021-12-17 18:45:26</td>\n",
       "      <td>据俄新社：俄罗斯建议北约放弃在乌克兰、东欧、高加索和中亚的所有军事活动。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>2021-12-17 18:43:33</td>\n",
       "      <td>据俄新社：俄罗斯建议北约和平解决所有争端，避免使用武力。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>2021-12-17 18:43:18</td>\n",
       "      <td>据俄新社：俄罗斯外交部向美国和北约公布有关安全保障的提案草案。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>2021-12-17 18:42:54</td>\n",
       "      <td>俄罗斯副外长：俄罗斯关于安全保障的建议不是向西方发出的最后通牒。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>2021-12-17 18:42:41</td>\n",
       "      <td>&lt;b&gt;【行情】美元兑俄罗斯卢布USD/RUB短线拉升，报73.8639，日内涨0.25%。&lt;/b&gt;</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>2021-12-17 18:42:23</td>\n",
       "      <td>【行情】美、布两油期货均跌超2%，报71.45美元/桶、73.56美元/桶。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>2021-12-17 18:40:11</td>\n",
       "      <td>俄罗斯副外长：俄罗斯没有为安全保障谈判设定任何最后期限，但呼吁立即开始谈判。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>2021-12-17 18:39:16</td>\n",
       "      <td>俄罗斯央行：最近数据也表明企业的物价预期保持在多年来高点附近。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>2021-12-17 18:39:00</td>\n",
       "      <td>【行情】现货钯金向上触及1800美元/盎司，日内涨4.38%。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>2021-12-17 18:38:39</td>\n",
       "      <td>【行情】富途控股(FUTU.O)盘前跌幅收窄至7.6%，老虎证券(TIGR.O)盘前现跌8....</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               datetime                                            content\n",
       "0   2021-12-17 19:33:28  <b>【直播进行中】面对英央行强势加息，黄金应如何布局？实时连线金十研究员，专业解读最新持仓...\n",
       "1   2021-12-17 19:33:26  <a href=\"https://v.jin10.com/live/index.html#/...\n",
       "2   2021-12-17 19:32:17                美国国家过敏症和传染病研究所所长福奇：看到了突破性感染病例，风险较低。\n",
       "3   2021-12-17 19:31:20                 <b>【行情】现货钯金涨超5%，报1824.27美元/盎司。</b>\n",
       "4   2021-12-17 19:29:01              据俄新社：俄罗斯总统普京称，俄罗斯的“卫星V”新冠疫苗对奥密克戎毒株有效。\n",
       "5   2021-12-17 19:25:31  【上海出口集装箱运价指数逼近4900点 再创历史新高】12月17日，上海航运交易所公布最新的...\n",
       "6   2021-12-17 19:24:42    12月17日0-18时，浙江绍兴新增确诊病例66例、无症状感染者1例，均在上虞区。（人民日报）\n",
       "7   2021-12-17 19:19:39                      【行情】欧盟基准碳价合约下跌11%，报75.28欧元/吨。\n",
       "8   2021-12-17 19:19:31          美国国家过敏症和传染病研究所所长福奇：奥密克戎毒株和德尔塔毒株的感染病例都在激增。\n",
       "9   2021-12-17 19:18:30                     俄罗斯副外长：准备最早在明天就拟议的安全保障开始与美国谈判。\n",
       "10  2021-12-17 19:17:15         德国总理朔尔茨发言人：不能保证德国央行行长魏德曼的继任者将于下周三在内阁中做出决定。\n",
       "11  2021-12-17 19:15:54                         德国总理朔尔茨发言人：德国央行行长候选人将很快公布。\n",
       "12  2021-12-17 19:09:44                               德国经济部：目前没有迹象表明天然气短缺。\n",
       "13  2021-12-17 19:07:31                       印度卫生官员：目前还没有足够的数据表明新型药物的有效性。\n",
       "14  2021-12-17 19:07:26                      【金十图示】2021年12月17日（周五）欧盘市场行情一览\n",
       "15  2021-12-17 19:06:45  习近平在主持会议时强调，要推动发展适合中国国情、政府政策支持、个人自愿参加、市场化运营的个人...\n",
       "16  2021-12-17 19:06:40  习近平12月17日下午主持召开中央全面深化改革委员会第二十三次会议，审议通过了《关于加快建设...\n",
       "17  2021-12-17 19:05:53  华人置业(00127.HK)在港公告：董事会谨此宣布，私有化计划于计划会议上遭到否决。将本公...\n",
       "18  2021-12-17 19:05:23                      <b>德国经济部：北溪二号不会在明年1月开始运营。</b>\n",
       "19  2021-12-17 19:04:50  据央视：习近平主持召开中央全面深化改革委员会第二十三次会议强调，加快建设全国统一大市场提高政...\n",
       "20  2021-12-17 19:03:43                             市场消息：北溪二号第二根管道正在注入天然气。\n",
       "21  2021-12-17 19:02:08          欧洲证券及市场管理局：希望与英国央行达成新的协议，以对伦敦清算机构拥有更大的权力。\n",
       "22  2021-12-17 19:01:52                  欧洲证券及市场管理局：目前切断伦敦欧元清算的成本和风险超过了收益。\n",
       "23  2021-12-17 19:01:13                      西班牙央行：通胀在2022年前几个月保持高位后将大幅放缓。\n",
       "24  2021-12-17 19:01:06       西班牙央行首席经济学家：西班牙经济要到2022年底或2023年初才能达到大流行前的水平。\n",
       "25  2021-12-17 19:00:48                  西班牙央行：2021年经济增速预期从9月份的6.3%降至4.5%。\n",
       "26  2021-12-17 18:58:39  贝壳(BEKE.N)否认浑水做空报告：昨日，浑水公司发布了一份攻击贝壳的做空报告。根据本公司...\n",
       "27  2021-12-17 18:57:04  香港特区政府卫生署卫生防护中心17日公布，截至当日零时，香港新增7例新冠肺炎输入病例。其中1...\n",
       "28  2021-12-17 18:56:11                          印度卫生官员：新冠阳性率高的地区应考虑限制性措施。\n",
       "29  2021-12-17 18:55:18                           印度卫生官员：需要避免不必要的旅行、大规模集会。\n",
       "30  2021-12-17 18:54:45                        据俄新社：俄罗斯表示美国不应与前苏联国家建立军事关系。\n",
       "31  2021-12-17 18:52:45                          据俄新社：俄罗斯建议美国不得在前苏联国家建立基地。\n",
       "32  2021-12-17 18:52:09                    德国卫生部发言人：政府正在调查英国是否应被列为变种病毒感染区。\n",
       "33  2021-12-17 18:51:49                        土耳其央行：因出现了不健康的价格结构，干预了外汇市场。\n",
       "34  2021-12-17 18:48:55                         印度卫生官员：已经发现101例奥密克戎毒株感染病例。\n",
       "35  2021-12-17 18:48:11       <b>【行情】美元兑土耳其里拉USD/TRY日内涨幅收窄至近5%，报16.50。</b>\n",
       "36  2021-12-17 18:47:28                                 市场消息：土耳其央行干预了外汇市场。\n",
       "37  2021-12-17 18:47:14     据俄新社：俄罗斯建议俄罗斯和美国不要在其领土外部署核武器，并撤回已经在其领土外部署的核武器。\n",
       "38  2021-12-17 18:46:39                  据俄新社：俄罗斯建议美国在平等安全的基础上合作，不损害彼此的安全。\n",
       "39  2021-12-17 18:46:11         据俄新社：草案显示，俄罗斯和北约承诺不会在可能击中对方领土的地区部署中程和短程导弹。\n",
       "40  2021-12-17 18:45:26               据俄新社：俄罗斯建议北约放弃在乌克兰、东欧、高加索和中亚的所有军事活动。\n",
       "41  2021-12-17 18:43:33                       据俄新社：俄罗斯建议北约和平解决所有争端，避免使用武力。\n",
       "42  2021-12-17 18:43:18                    据俄新社：俄罗斯外交部向美国和北约公布有关安全保障的提案草案。\n",
       "43  2021-12-17 18:42:54                   俄罗斯副外长：俄罗斯关于安全保障的建议不是向西方发出的最后通牒。\n",
       "44  2021-12-17 18:42:41  <b>【行情】美元兑俄罗斯卢布USD/RUB短线拉升，报73.8639，日内涨0.25%。</b>\n",
       "45  2021-12-17 18:42:23             【行情】美、布两油期货均跌超2%，报71.45美元/桶、73.56美元/桶。\n",
       "46  2021-12-17 18:40:11             俄罗斯副外长：俄罗斯没有为安全保障谈判设定任何最后期限，但呼吁立即开始谈判。\n",
       "47  2021-12-17 18:39:16                    俄罗斯央行：最近数据也表明企业的物价预期保持在多年来高点附近。\n",
       "48  2021-12-17 18:39:00                    【行情】现货钯金向上触及1800美元/盎司，日内涨4.38%。\n",
       "49  2021-12-17 18:38:39  【行情】富途控股(FUTU.O)盘前跌幅收窄至7.6%，老虎证券(TIGR.O)盘前现跌8...."
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "t = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n",
    "ak.js_news(timestamp=t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol=\"000001\", period=\"daily\", start_date=\"20170301\", end_date='20210907', adjust=\"hfq\")\n",
    "# for d, row in stock_zh_a_hist_df.iterrows():\n",
    "#     print(d, row[1:5])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_zh_a_hist_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = 0\n",
    "for dates, row in stock_zh_a_hist_df.iterrows():\n",
    "    # 将时间转换为数字\n",
    "    # date_time = datetime.strptime(dates, '%Y-%m-%d')\n",
    "    # t = date2num(date_time)\n",
    "    open, close, high, low = row[1:5]\n",
    "    datas = (d, open, close, low, high)\n",
    "    print(datas)\n",
    "    d += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>日期</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-03-01</th>\n",
       "      <td>2017-03-01</td>\n",
       "      <td>1575.20</td>\n",
       "      <td>1575.20</td>\n",
       "      <td>1584.95</td>\n",
       "      <td>1571.95</td>\n",
       "      <td>346994</td>\n",
       "      <td>3.301580e+08</td>\n",
       "      <td>0.83</td>\n",
       "      <td>0.10</td>\n",
       "      <td>1.63</td>\n",
       "      <td>0.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-02</th>\n",
       "      <td>2017-03-02</td>\n",
       "      <td>1578.45</td>\n",
       "      <td>1565.45</td>\n",
       "      <td>1583.32</td>\n",
       "      <td>1563.82</td>\n",
       "      <td>403629</td>\n",
       "      <td>3.823959e+08</td>\n",
       "      <td>1.24</td>\n",
       "      <td>-0.62</td>\n",
       "      <td>-9.75</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-03</th>\n",
       "      <td>2017-03-03</td>\n",
       "      <td>1562.20</td>\n",
       "      <td>1560.57</td>\n",
       "      <td>1565.45</td>\n",
       "      <td>1554.07</td>\n",
       "      <td>342655</td>\n",
       "      <td>3.219525e+08</td>\n",
       "      <td>0.73</td>\n",
       "      <td>-0.31</td>\n",
       "      <td>-4.88</td>\n",
       "      <td>0.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-06</th>\n",
       "      <td>2017-03-06</td>\n",
       "      <td>1560.57</td>\n",
       "      <td>1568.70</td>\n",
       "      <td>1570.32</td>\n",
       "      <td>1558.95</td>\n",
       "      <td>404511</td>\n",
       "      <td>3.812123e+08</td>\n",
       "      <td>0.73</td>\n",
       "      <td>0.52</td>\n",
       "      <td>8.13</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-07</th>\n",
       "      <td>2017-03-07</td>\n",
       "      <td>1567.07</td>\n",
       "      <td>1568.70</td>\n",
       "      <td>1570.32</td>\n",
       "      <td>1560.57</td>\n",
       "      <td>294673</td>\n",
       "      <td>2.777474e+08</td>\n",
       "      <td>0.62</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-01</th>\n",
       "      <td>2021-09-01</td>\n",
       "      <td>3009.83</td>\n",
       "      <td>3074.84</td>\n",
       "      <td>3081.34</td>\n",
       "      <td>2933.44</td>\n",
       "      <td>2316894</td>\n",
       "      <td>4.046284e+09</td>\n",
       "      <td>4.83</td>\n",
       "      <td>0.42</td>\n",
       "      <td>13.00</td>\n",
       "      <td>1.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-02</th>\n",
       "      <td>2021-09-02</td>\n",
       "      <td>3094.34</td>\n",
       "      <td>3159.35</td>\n",
       "      <td>3221.11</td>\n",
       "      <td>3061.84</td>\n",
       "      <td>2422604</td>\n",
       "      <td>4.454545e+09</td>\n",
       "      <td>5.18</td>\n",
       "      <td>2.75</td>\n",
       "      <td>84.51</td>\n",
       "      <td>1.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-03</th>\n",
       "      <td>2021-09-03</td>\n",
       "      <td>3175.61</td>\n",
       "      <td>3100.84</td>\n",
       "      <td>3175.61</td>\n",
       "      <td>3045.58</td>\n",
       "      <td>1394819</td>\n",
       "      <td>2.523273e+09</td>\n",
       "      <td>4.12</td>\n",
       "      <td>-1.85</td>\n",
       "      <td>-58.51</td>\n",
       "      <td>0.72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-06</th>\n",
       "      <td>2021-09-06</td>\n",
       "      <td>3082.97</td>\n",
       "      <td>3167.48</td>\n",
       "      <td>3191.86</td>\n",
       "      <td>3058.59</td>\n",
       "      <td>1515226</td>\n",
       "      <td>2.780281e+09</td>\n",
       "      <td>4.30</td>\n",
       "      <td>2.15</td>\n",
       "      <td>66.64</td>\n",
       "      <td>0.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-07</th>\n",
       "      <td>2021-09-07</td>\n",
       "      <td>3191.86</td>\n",
       "      <td>3295.88</td>\n",
       "      <td>3347.89</td>\n",
       "      <td>3151.23</td>\n",
       "      <td>1622344</td>\n",
       "      <td>3.067366e+09</td>\n",
       "      <td>6.21</td>\n",
       "      <td>4.05</td>\n",
       "      <td>128.40</td>\n",
       "      <td>0.84</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1105 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期       开盘       收盘       最高       最低      成交量  \\\n",
       "日期                                                                    \n",
       "2017-03-01  2017-03-01  1575.20  1575.20  1584.95  1571.95   346994   \n",
       "2017-03-02  2017-03-02  1578.45  1565.45  1583.32  1563.82   403629   \n",
       "2017-03-03  2017-03-03  1562.20  1560.57  1565.45  1554.07   342655   \n",
       "2017-03-06  2017-03-06  1560.57  1568.70  1570.32  1558.95   404511   \n",
       "2017-03-07  2017-03-07  1567.07  1568.70  1570.32  1560.57   294673   \n",
       "...                ...      ...      ...      ...      ...      ...   \n",
       "2021-09-01  2021-09-01  3009.83  3074.84  3081.34  2933.44  2316894   \n",
       "2021-09-02  2021-09-02  3094.34  3159.35  3221.11  3061.84  2422604   \n",
       "2021-09-03  2021-09-03  3175.61  3100.84  3175.61  3045.58  1394819   \n",
       "2021-09-06  2021-09-06  3082.97  3167.48  3191.86  3058.59  1515226   \n",
       "2021-09-07  2021-09-07  3191.86  3295.88  3347.89  3151.23  1622344   \n",
       "\n",
       "                     成交额    振幅   涨跌幅     涨跌额   换手率  \n",
       "日期                                                  \n",
       "2017-03-01  3.301580e+08  0.83  0.10    1.63  0.21  \n",
       "2017-03-02  3.823959e+08  1.24 -0.62   -9.75  0.24  \n",
       "2017-03-03  3.219525e+08  0.73 -0.31   -4.88  0.20  \n",
       "2017-03-06  3.812123e+08  0.73  0.52    8.13  0.24  \n",
       "2017-03-07  2.777474e+08  0.62  0.00    0.00  0.17  \n",
       "...                  ...   ...   ...     ...   ...  \n",
       "2021-09-01  4.046284e+09  4.83  0.42   13.00  1.19  \n",
       "2021-09-02  4.454545e+09  5.18  2.75   84.51  1.25  \n",
       "2021-09-03  2.523273e+09  4.12 -1.85  -58.51  0.72  \n",
       "2021-09-06  2.780281e+09  4.30  2.15   66.64  0.78  \n",
       "2021-09-07  3.067366e+09  6.21  4.05  128.40  0.84  \n",
       "\n",
       "[1105 rows x 11 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_hist_df.index = pd.to_datetime(stock_zh_a_hist_df['日期'])\n",
    "stock_zh_a_hist_df.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "日期\n",
       "2017-12-31    0.409415\n",
       "2018-12-31   -0.277018\n",
       "2019-12-31    0.730571\n",
       "2020-12-31    0.181853\n",
       "2021-12-31    0.003960\n",
       "Freq: A-DEC, Name: 收盘, dtype: float64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chg = TSeries((stock_zh_a_hist_df['收盘'] / stock_zh_a_hist_df['收盘'].shift(1) - 1).dropna())\n",
    "chg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        序号      代码    名称    最新价    涨跌幅    涨跌额       成交量           成交额     振幅  \\\n",
      "0        1  301100   N风光  54.18  94.82  26.37  328217.0  1.884441e+09  52.32   \n",
      "1        2  300466  赛摩智能   8.57  20.03   1.43  378562.0  3.244273e+08   0.00   \n",
      "2        3  300120  经纬辉开  10.43  20.02   1.74  938000.0  9.420404e+08  21.52   \n",
      "3        4  300713   英可瑞  25.06  20.02   4.18  153251.0  3.675313e+08  20.83   \n",
      "4        5  300250  初灵信息  15.41  20.02   2.57  385063.0  5.746433e+08  15.03   \n",
      "...    ...     ...   ...    ...    ...    ...       ...           ...    ...   \n",
      "4832  4833  300943  春晖智控  35.46 -10.45  -4.14  114979.0  4.270154e+08   8.36   \n",
      "4833  4834  301072  中捷精工  42.04 -10.48  -4.92   75007.0  3.282510e+08   9.60   \n",
      "4834  4835  300224  正海磁材  16.98 -10.49  -1.99  782301.0  1.379355e+09   8.91   \n",
      "4835  4836  300813  泰林生物  88.35 -11.73 -11.74   28254.0  2.625338e+08   9.85   \n",
      "4836  4837  301168  通灵股份  66.75 -14.64 -11.45  147569.0  1.078993e+09  20.98   \n",
      "\n",
      "         最高     最低     今开      昨收     量比    换手率  市盈率-动态   市净率  \n",
      "0     66.13  51.58  51.98   27.81    NaN  69.21   80.88  4.91  \n",
      "1      8.57   8.57   8.57    7.14   2.65   9.01  205.12  5.27  \n",
      "2     10.43   8.56   8.65    8.69  11.28  24.54   74.39  1.93  \n",
      "3     25.06  20.71  20.89   20.88   2.48  16.94  176.90  5.36  \n",
      "4     15.41  13.48  13.48   12.84   6.77  24.17   66.06  5.09  \n",
      "...     ...    ...    ...     ...    ...    ...     ...   ...  \n",
      "4832  38.77  35.46  38.13   39.60   0.99  37.57   61.61  5.80  \n",
      "4833  46.50  41.99  46.00   46.96   1.07  30.12   80.27  5.78  \n",
      "4834  18.55  16.86  18.45   18.97   0.95   9.63   56.90  5.20  \n",
      "4835  97.61  87.75  97.61  100.09   2.34  17.36   81.27  9.46  \n",
      "4836  82.99  66.58  78.00   78.20   0.93  51.87   94.79  4.40  \n",
      "\n",
      "[4837 rows x 17 columns]\n"
     ]
    }
   ],
   "source": [
    "stock_zh_a_spot_em_df = ak.stock_zh_a_spot_em()\n",
    "print(stock_zh_a_spot_em_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>今开</th>\n",
       "      <th>昨收</th>\n",
       "      <th>量比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>市盈率-动态</th>\n",
       "      <th>市净率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2460</th>\n",
       "      <td>2461</td>\n",
       "      <td>000001</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>17.57</td>\n",
       "      <td>-0.85</td>\n",
       "      <td>-0.15</td>\n",
       "      <td>602370.0</td>\n",
       "      <td>1.062875e+09</td>\n",
       "      <td>1.02</td>\n",
       "      <td>17.75</td>\n",
       "      <td>17.57</td>\n",
       "      <td>17.7</td>\n",
       "      <td>17.72</td>\n",
       "      <td>0.47</td>\n",
       "      <td>0.31</td>\n",
       "      <td>8.78</td>\n",
       "      <td>1.07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号      代码    名称    最新价   涨跌幅   涨跌额       成交量           成交额    振幅  \\\n",
       "2460  2461  000001  平安银行  17.57 -0.85 -0.15  602370.0  1.062875e+09  1.02   \n",
       "\n",
       "         最高     最低    今开     昨收    量比   换手率  市盈率-动态   市净率  \n",
       "2460  17.75  17.57  17.7  17.72  0.47  0.31    8.78  1.07  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_spot_em_df[stock_zh_a_spot_em_df['代码'] == '000001']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                         \r"
     ]
    }
   ],
   "source": [
    "data = ak.stock_zh_a_spot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>买入</th>\n",
       "      <th>卖出</th>\n",
       "      <th>昨收</th>\n",
       "      <th>今开</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>bj430047</td>\n",
       "      <td>诺思兰德</td>\n",
       "      <td>29.13</td>\n",
       "      <td>3.15</td>\n",
       "      <td>12.125</td>\n",
       "      <td>29.11</td>\n",
       "      <td>29.13</td>\n",
       "      <td>25.98</td>\n",
       "      <td>26.12</td>\n",
       "      <td>29.46</td>\n",
       "      <td>26.06</td>\n",
       "      <td>6776308.0</td>\n",
       "      <td>1.906196e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bj430090</td>\n",
       "      <td>同辉信息</td>\n",
       "      <td>7.78</td>\n",
       "      <td>0.34</td>\n",
       "      <td>4.570</td>\n",
       "      <td>7.77</td>\n",
       "      <td>7.78</td>\n",
       "      <td>7.44</td>\n",
       "      <td>7.43</td>\n",
       "      <td>7.99</td>\n",
       "      <td>7.21</td>\n",
       "      <td>10047272.0</td>\n",
       "      <td>7.790151e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>bj430198</td>\n",
       "      <td>微创光电</td>\n",
       "      <td>9.41</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.423</td>\n",
       "      <td>9.41</td>\n",
       "      <td>9.45</td>\n",
       "      <td>9.45</td>\n",
       "      <td>9.43</td>\n",
       "      <td>9.59</td>\n",
       "      <td>9.39</td>\n",
       "      <td>315286.0</td>\n",
       "      <td>2.969310e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>bj430418</td>\n",
       "      <td>苏轴股份</td>\n",
       "      <td>14.91</td>\n",
       "      <td>-0.47</td>\n",
       "      <td>-3.056</td>\n",
       "      <td>14.90</td>\n",
       "      <td>14.91</td>\n",
       "      <td>15.38</td>\n",
       "      <td>15.24</td>\n",
       "      <td>15.25</td>\n",
       "      <td>14.91</td>\n",
       "      <td>115883.0</td>\n",
       "      <td>1.749287e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>bj430489</td>\n",
       "      <td>佳先股份</td>\n",
       "      <td>13.32</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.150</td>\n",
       "      <td>13.32</td>\n",
       "      <td>13.33</td>\n",
       "      <td>13.34</td>\n",
       "      <td>13.48</td>\n",
       "      <td>13.67</td>\n",
       "      <td>13.32</td>\n",
       "      <td>679484.0</td>\n",
       "      <td>9.116509e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4657</th>\n",
       "      <td>sz301188</td>\n",
       "      <td>力诺特玻</td>\n",
       "      <td>25.86</td>\n",
       "      <td>-1.05</td>\n",
       "      <td>-3.902</td>\n",
       "      <td>25.86</td>\n",
       "      <td>25.87</td>\n",
       "      <td>26.91</td>\n",
       "      <td>26.87</td>\n",
       "      <td>26.87</td>\n",
       "      <td>25.82</td>\n",
       "      <td>6501348.0</td>\n",
       "      <td>1.700806e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4658</th>\n",
       "      <td>sz301193</td>\n",
       "      <td>家联科技</td>\n",
       "      <td>36.20</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.055</td>\n",
       "      <td>36.19</td>\n",
       "      <td>36.20</td>\n",
       "      <td>36.22</td>\n",
       "      <td>36.30</td>\n",
       "      <td>38.35</td>\n",
       "      <td>36.19</td>\n",
       "      <td>8774876.0</td>\n",
       "      <td>3.256411e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4659</th>\n",
       "      <td>sz301198</td>\n",
       "      <td>喜悦智行</td>\n",
       "      <td>40.79</td>\n",
       "      <td>-3.17</td>\n",
       "      <td>-7.211</td>\n",
       "      <td>40.79</td>\n",
       "      <td>40.80</td>\n",
       "      <td>43.96</td>\n",
       "      <td>42.84</td>\n",
       "      <td>43.00</td>\n",
       "      <td>40.78</td>\n",
       "      <td>7269444.0</td>\n",
       "      <td>3.033318e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4660</th>\n",
       "      <td>sz301199</td>\n",
       "      <td>迈赫股份</td>\n",
       "      <td>40.29</td>\n",
       "      <td>0.34</td>\n",
       "      <td>0.851</td>\n",
       "      <td>40.29</td>\n",
       "      <td>40.30</td>\n",
       "      <td>39.95</td>\n",
       "      <td>39.86</td>\n",
       "      <td>43.40</td>\n",
       "      <td>39.80</td>\n",
       "      <td>11597312.0</td>\n",
       "      <td>4.812444e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4661</th>\n",
       "      <td>sz301213</td>\n",
       "      <td>观想科技</td>\n",
       "      <td>82.48</td>\n",
       "      <td>3.35</td>\n",
       "      <td>4.234</td>\n",
       "      <td>82.40</td>\n",
       "      <td>82.48</td>\n",
       "      <td>79.13</td>\n",
       "      <td>90.00</td>\n",
       "      <td>94.96</td>\n",
       "      <td>82.00</td>\n",
       "      <td>14102601.0</td>\n",
       "      <td>1.248545e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4662 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            代码    名称    最新价   涨跌额     涨跌幅     买入     卖出     昨收     今开     最高  \\\n",
       "0     bj430047  诺思兰德  29.13  3.15  12.125  29.11  29.13  25.98  26.12  29.46   \n",
       "1     bj430090  同辉信息   7.78  0.34   4.570   7.77   7.78   7.44   7.43   7.99   \n",
       "2     bj430198  微创光电   9.41 -0.04  -0.423   9.41   9.45   9.45   9.43   9.59   \n",
       "3     bj430418  苏轴股份  14.91 -0.47  -3.056  14.90  14.91  15.38  15.24  15.25   \n",
       "4     bj430489  佳先股份  13.32 -0.02  -0.150  13.32  13.33  13.34  13.48  13.67   \n",
       "...        ...   ...    ...   ...     ...    ...    ...    ...    ...    ...   \n",
       "4657  sz301188  力诺特玻  25.86 -1.05  -3.902  25.86  25.87  26.91  26.87  26.87   \n",
       "4658  sz301193  家联科技  36.20 -0.02  -0.055  36.19  36.20  36.22  36.30  38.35   \n",
       "4659  sz301198  喜悦智行  40.79 -3.17  -7.211  40.79  40.80  43.96  42.84  43.00   \n",
       "4660  sz301199  迈赫股份  40.29  0.34   0.851  40.29  40.30  39.95  39.86  43.40   \n",
       "4661  sz301213  观想科技  82.48  3.35   4.234  82.40  82.48  79.13  90.00  94.96   \n",
       "\n",
       "         最低         成交量           成交额  \n",
       "0     26.06   6776308.0  1.906196e+08  \n",
       "1      7.21  10047272.0  7.790151e+07  \n",
       "2      9.39    315286.0  2.969310e+06  \n",
       "3     14.91    115883.0  1.749287e+06  \n",
       "4     13.32    679484.0  9.116509e+06  \n",
       "...     ...         ...           ...  \n",
       "4657  25.82   6501348.0  1.700806e+08  \n",
       "4658  36.19   8774876.0  3.256411e+08  \n",
       "4659  40.78   7269444.0  3.033318e+08  \n",
       "4660  39.80  11597312.0  4.812444e+08  \n",
       "4661  82.00  14102601.0  1.248545e+09  \n",
       "\n",
       "[4662 rows x 13 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>买入</th>\n",
       "      <th>卖出</th>\n",
       "      <th>昨收</th>\n",
       "      <th>今开</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [代码, 名称, 最新价, 涨跌额, 涨跌幅, 买入, 卖出, 昨收, 今开, 最高, 最低, 成交量, 成交额]\n",
       "Index: []"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['名称'] == '上证指数']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>收盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>换手率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2021-12-17</td>\n",
       "      <td>3045.58</td>\n",
       "      <td>3024.46</td>\n",
       "      <td>3053.71</td>\n",
       "      <td>3024.46</td>\n",
       "      <td>602370</td>\n",
       "      <td>1.062875e+09</td>\n",
       "      <td>0.96</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-24.38</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           日期       开盘       收盘       最高       最低     成交量           成交额    振幅  \\\n",
       "0  2021-12-17  3045.58  3024.46  3053.71  3024.46  602370  1.062875e+09  0.96   \n",
       "\n",
       "   涨跌幅    涨跌额   换手率  \n",
       "0 -0.8 -24.38  0.31  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol=\"000001\", period=\"daily\", start_date=\"20211217\", end_date='20211217', adjust=\"hfq\")\n",
    "stock_zh_a_hist_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-24.38"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_hist_df['涨跌额'][0]"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "0d008810b9c8467bcb3ca39aa2180e5b81b3a9acb136aab30d47954377cc5120"
  },
  "kernelspec": {
   "display_name": "Python 3.9.2 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
